home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Floating point calculation order
- Date: Thu, 25 Jan 96 20:06:31 GMT
- Organization: none
- Message-ID: <822600391snz@genesis.demon.co.uk>
- References: <m0tedv8-0002eqC@sice.nsk.su> <3104c6d9.134061184@nntp.ix.netcom.com> <TANMOY.96Jan23144637@qcd.lanl.gov> <DLpF0C.IH4@microunity.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <DLpF0C.IH4@microunity.com> toms@MicroUnity.com "Tom Sanders" writes:
-
- >As to the original equation `p * q / r' , I would argue that parentheses
- >are certainly necessary. There is a slight numeric difference between
- >`(p * q) / r' and `p * (q / r)' . By specifying I am sure the order I
- >prefer will be used no matter what compiler I am using.
-
- If a compiler is broken enough to evaluate p * q / r as p * (q / r) it is
- likely to evaluate (p * q) / r the same way (since in C they have always
- meant exactly the same thing and parentheses are unlikely to have any effect
- in the compiler beyond the initial syntax parsing stage). So the *only*
- reason for using parentheses in this case is readability. If you want to
- pander to non-standard/broken compilers you would have to write it as
- something like:
-
- tmp = p * q, tmp / r
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-